# Copyright (C) 2008-2022 TrinityCore <http://www.trinitycore.org/>
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# NOTE: Do not use glob here, it would include files we don't want
set(ace_STAT_SRCS
  Abstract_Timer_Queue.cpp
  Acceptor.cpp
  ACE.cpp
  ACE_crc_ccitt.cpp
  ACE_crc32.cpp
  ace_wchar.cpp
  Activation_Queue.cpp
  Active_Map_Manager.cpp
  Active_Map_Manager_T.cpp
  Addr.cpp
  Arg_Shifter.cpp
  ARGV.cpp
  Argv_Type_Converter.cpp
  Array_Base.cpp
  Array_Map.cpp
  Assert.cpp
  Asynch_Acceptor.cpp
  Asynch_Connector.cpp
  Asynch_IO.cpp
  Asynch_IO_Impl.cpp
  Asynch_Pseudo_Task.cpp
  ATM_Acceptor.cpp
  ATM_Addr.cpp
  ATM_Connector.cpp
  ATM_Params.cpp
  ATM_QoS.cpp
  ATM_Stream.cpp
  Atomic_Op.cpp
  Atomic_Op_GCC_T.cpp
  Atomic_Op_Sparc.c
  Atomic_Op_T.cpp
  Auto_Event.cpp
  Auto_Functor.cpp
  Auto_IncDec_T.cpp
  Auto_Ptr.cpp
  Barrier.cpp
  Base_Thread_Adapter.cpp
  Based_Pointer_Repository.cpp
  Based_Pointer_T.cpp
  Basic_Stats.cpp
  Basic_Types.cpp
  Bound_Ptr.cpp
  Cache_Map_Manager_T.cpp
  Cached_Connect_Strategy_T.cpp
  Caching_Strategies_T.cpp
  Caching_Utility_T.cpp
  Capabilities.cpp
  CDR_Base.cpp
  CDR_Size.cpp
  CDR_Stream.cpp
  CE_Screen_Output.cpp
  Cleanup.cpp
  Cleanup_Strategies_T.cpp
  Codecs.cpp
  Codeset_IBM1047.cpp
  Codeset_Registry.cpp
  Codeset_Registry_db.cpp
  Condition_Attributes.cpp
  Condition_Recursive_Thread_Mutex.cpp
  Condition_T.cpp
  Condition_Thread_Mutex.cpp
  Configuration.cpp
  Configuration_Import_Export.cpp
  Connection_Recycling_Strategy.cpp
  Connector.cpp
  Containers.cpp
  Containers_T.cpp
  Copy_Disabled.cpp
  Countdown_Time_T.cpp
  Date_Time.cpp
  DEV.cpp
  DEV_Addr.cpp
  DEV_Connector.cpp
  DEV_IO.cpp
  Dev_Poll_Reactor.cpp
  Dirent.cpp
  Dirent_Selector.cpp
  DLL.cpp
  DLL_Manager.cpp
  Dump.cpp
  Dump_T.cpp
  Dynamic.cpp
  Dynamic_Message_Strategy.cpp
  Dynamic_Service.cpp
  Dynamic_Service_Base.cpp
  Dynamic_Service_Dependency.cpp
  Encoding_Converter.cpp
  Encoding_Converter_Factory.cpp
  Env_Value_T.cpp
  Event.cpp
  Event_Base.cpp
  Event_Handler.cpp
  Event_Handler_Handle_Timeout_Upcall.cpp
  Event_Handler_T.cpp
  FIFO.cpp
  FIFO_Recv.cpp
  FIFO_Recv_Msg.cpp
  FIFO_Send.cpp
  FIFO_Send_Msg.cpp
  FILE.cpp
  FILE_Addr.cpp
  FILE_Connector.cpp
  FILE_IO.cpp
  File_Lock.cpp
  Filecache.cpp
  Flag_Manip.cpp
  Framework_Component.cpp
  Framework_Component_T.cpp
  Free_List.cpp
  Functor.cpp
  Functor_String.cpp
  Functor_T.cpp
  Future.cpp
  Future_Set.cpp
  Get_Opt.cpp
  Guard_T.cpp
  Handle_Ops.cpp
  Handle_Set.cpp
  Hash_Cache_Map_Manager_T.cpp
  Hash_Map_Manager_T.cpp
  Hash_Map_With_Allocator_T.cpp
  Hash_Multi_Map_Manager_T.cpp
  Hashable.cpp
  High_Res_Timer.cpp
  ICMP_Socket.cpp
  INET_Addr.cpp
  Init_ACE.cpp
  Intrusive_Auto_Ptr.cpp
  Intrusive_List.cpp
  Intrusive_List_Node.cpp
  IO_Cntl_Msg.cpp
  IO_SAP.cpp
  IOStream.cpp
  IOStream_T.cpp
  IPC_SAP.cpp
  Lib_Find.cpp
  Local_Memory_Pool.cpp
  Local_Name_Space.cpp
  Local_Name_Space_T.cpp
  Local_Tokens.cpp
  Lock.cpp
  Lock_Adapter_T.cpp
  LOCK_SOCK_Acceptor.cpp
  Log_Category.cpp
  Log_Msg.cpp
  Log_Msg_Backend.cpp
  Log_Msg_Callback.cpp
  Log_Msg_IPC.cpp
  Log_Msg_NT_Event_Log.cpp
  Log_Msg_UNIX_Syslog.cpp
  Log_Record.cpp
  Logging_Strategy.cpp
  LSOCK.cpp
  LSOCK_Acceptor.cpp
  LSOCK_CODgram.cpp
  LSOCK_Connector.cpp
  LSOCK_Dgram.cpp
  LSOCK_Stream.cpp
  Malloc.cpp
  Malloc_Allocator.cpp
  Malloc_T.cpp
  Managed_Object.cpp
  Manual_Event.cpp
  Map_Manager.cpp
  Map_T.cpp
  MEM_Acceptor.cpp
  MEM_Addr.cpp
  MEM_Connector.cpp
  MEM_IO.cpp
  Mem_Map.cpp
  MEM_SAP.cpp
  MEM_Stream.cpp
  Message_Block.cpp
  Message_Block_T.cpp
  Message_Queue.cpp
  Message_Queue_NT.cpp
  Message_Queue_T.cpp
  Message_Queue_Vx.cpp
  Method_Request.cpp
  Metrics_Cache_T.cpp
  MMAP_Memory_Pool.cpp
  Module.cpp
  Monitor_Admin.cpp
  Monitor_Admin_Manager.cpp
  Monitor_Base.cpp
  Monitor_Control_Action.cpp
  Monitor_Control_Types.cpp
  Monitor_Point_Registry.cpp
  Monitor_Size.cpp
  Monotonic_Time_Policy.cpp
  Msg_WFMO_Reactor.cpp
  Multihomed_INET_Addr.cpp
  Mutex.cpp
  Name_Proxy.cpp
  Name_Request_Reply.cpp
  Name_Space.cpp
  Naming_Context.cpp
  Netlink_Addr.cpp
  Node.cpp
  Notification_Queue.cpp
  Notification_Strategy.cpp
  NT_Service.cpp
  Null_Mutex.cpp
  Obchunk.cpp
  Object_Manager.cpp
  Object_Manager_Base.cpp
  Obstack.cpp
  Obstack_T.cpp
  OS_Errno.cpp
  OS_Log_Msg_Attributes.cpp
  OS_main.cpp
  OS_NS_arpa_inet.cpp
  OS_NS_ctype.cpp
  OS_NS_devctl.cpp
  OS_NS_dirent.cpp
  OS_NS_dlfcn.cpp
  OS_NS_errno.cpp
  OS_NS_fcntl.cpp
  OS_NS_math.cpp
  OS_NS_netdb.cpp
  OS_NS_poll.cpp
  OS_NS_pwd.cpp
  OS_NS_regex.cpp
  OS_NS_signal.cpp
  OS_NS_stdio.cpp
  OS_NS_stdlib.cpp
  OS_NS_string.cpp
  OS_NS_strings.cpp
  OS_NS_stropts.cpp
  OS_NS_sys_mman.cpp
  OS_NS_sys_msg.cpp
  OS_NS_sys_resource.cpp
  OS_NS_sys_select.cpp
  OS_NS_sys_sendfile.cpp
  OS_NS_sys_shm.cpp
  OS_NS_sys_socket.cpp
  OS_NS_sys_stat.cpp
  OS_NS_sys_time.cpp
  OS_NS_sys_uio.cpp
  OS_NS_sys_utsname.cpp
  OS_NS_sys_wait.cpp
  OS_NS_Thread.cpp
  OS_NS_time.cpp
  OS_NS_unistd.cpp
  OS_NS_wchar.cpp
  OS_NS_wctype.cpp
  OS_QoS.cpp
  OS_Thread_Adapter.cpp
  OS_TLI.cpp
  Pagefile_Memory_Pool.cpp
  Pair_T.cpp
  Parse_Node.cpp
  PI_Malloc.cpp
  Ping_Socket.cpp
  Pipe.cpp
  POSIX_Asynch_IO.cpp
  POSIX_CB_Proactor.cpp
  POSIX_Proactor.cpp
  Priority_Reactor.cpp
  Proactor.cpp
  Proactor_Impl.cpp
  Process.cpp
  Process_Manager.cpp
  Process_Mutex.cpp
  Process_Semaphore.cpp
  Profile_Timer.cpp
  RB_Tree.cpp
  Reactor.cpp
  Reactor_Impl.cpp
  Reactor_Notification_Strategy.cpp
  Reactor_Timer_Interface.cpp
  Read_Buffer.cpp
  Recursive_Thread_Mutex.cpp
  Recyclable.cpp
  Refcountable_T.cpp
  Refcounted_Auto_Ptr.cpp
  Registry.cpp
  Registry_Name_Space.cpp
  Remote_Name_Space.cpp
  Remote_Tokens.cpp
  Reverse_Lock_T.cpp
  Rtems_init.c
  RW_Mutex.cpp
  RW_Process_Mutex.cpp
  RW_Thread_Mutex.cpp
  Sample_History.cpp
  Sbrk_Memory_Pool.cpp
  Sched_Params.cpp
  Select_Reactor_Base.cpp
  Select_Reactor_T.cpp
  Semaphore.cpp
  Service_Config.cpp
  Service_Gestalt.cpp
  Service_Manager.cpp
  Service_Object.cpp
  Service_Repository.cpp
  Service_Types.cpp
  Shared_Memory.cpp
  Shared_Memory_MM.cpp
  Shared_Memory_Pool.cpp
  Shared_Memory_SV.cpp
  Shared_Object.cpp
  Sig_Adapter.cpp
  Sig_Handler.cpp
  Signal.cpp
  Singleton.cpp
  SOCK.cpp
  SOCK_Acceptor.cpp
  SOCK_CODgram.cpp
  Sock_Connect.cpp
  SOCK_Connector.cpp
  SOCK_Dgram.cpp
  SOCK_Dgram_Bcast.cpp
  SOCK_IO.cpp
  SOCK_Netlink.cpp
  SOCK_SEQPACK_Acceptor.cpp
  SOCK_SEQPACK_Association.cpp
  SOCK_SEQPACK_Connector.cpp
  SOCK_Stream.cpp
  SPIPE.cpp
  SPIPE_Acceptor.cpp
  SPIPE_Addr.cpp
  SPIPE_Connector.cpp
  SPIPE_Stream.cpp
  SString.cpp
  Stack_Trace.cpp
  Stats.cpp
  Strategies_T.cpp
  Stream.cpp
  Stream_Modules.cpp
  String_Base.cpp
  String_Base_Const.cpp
  SUN_Proactor.cpp
  SV_Message.cpp
  SV_Message_Queue.cpp
  SV_Semaphore_Complex.cpp
  SV_Semaphore_Simple.cpp
  SV_Shared_Memory.cpp
  Svc_Conf_Lexer.cpp
  Svc_Conf_y.cpp
  Svc_Handler.cpp
  Synch_Options.cpp
  System_Time.cpp
  Task.cpp
  Task_Ex_T.cpp
  Task_T.cpp
  Test_and_Set.cpp
  Thread.cpp
  Thread_Adapter.cpp
  Thread_Control.cpp
  Thread_Exit.cpp
  Thread_Hook.cpp
  Thread_Manager.cpp
  Thread_Mutex.cpp
  Thread_Semaphore.cpp
  Throughput_Stats.cpp
  Time_Policy.cpp
  Time_Policy_T.cpp
  Time_Value.cpp
  Time_Value_T.cpp
  Timeprobe.cpp
  Timeprobe_T.cpp
  Timer_Hash_T.cpp
  Timer_Heap_T.cpp
  Timer_List_T.cpp
  Timer_Queue_Adapters.cpp
  Timer_Queue_Iterator.cpp
  Timer_Queue_T.cpp
  Timer_Wheel_T.cpp
  TLI.cpp
  TLI_Acceptor.cpp
  TLI_Connector.cpp
  TLI_Stream.cpp
  Token.cpp
  Token_Collection.cpp
  Token_Invariants.cpp
  Token_Manager.cpp
  Token_Request_Reply.cpp
  Tokenizer_T.cpp
  TP_Reactor.cpp
  Trace.cpp
  TSS_Adapter.cpp
  TSS_T.cpp
  TTY_IO.cpp
  Typed_SV_Message.cpp
  Typed_SV_Message_Queue.cpp
  Unbounded_Queue.cpp
  Unbounded_Set.cpp
  Unbounded_Set_Ex.cpp
  UNIX_Addr.cpp
  UPIPE_Acceptor.cpp
  UPIPE_Connector.cpp
  UPIPE_Stream.cpp
  UTF8_Encoding_Converter.cpp
  UTF16_Encoding_Converter.cpp
  UTF32_Encoding_Converter.cpp
  UUID.cpp
  Vector_T.cpp
  WFMO_Reactor.cpp
  WIN32_Asynch_IO.cpp
  WIN32_Proactor.cpp
  XML_Svc_Conf.cpp
  XTI_ATM_Mcast.cpp
)

if (USE_COREPCH)
  set(ace_PCH_HDR PrecompiledHeaders/WinAcePCH.h)
endif()

include_directories(
  ${CMAKE_SOURCE_DIR}/dep/acelite
  ${CMAKE_CURRENT_SOURCE_DIR}/Compression
  ${CMAKE_CURRENT_SOURCE_DIR}/Compression/rle
  ${CMAKE_CURRENT_SOURCE_DIR}/ETCL
  ${CMAKE_CURRENT_SOURCE_DIR}/FIReactor
  ${CMAKE_CURRENT_SOURCE_DIR}/FoxReactor
  ${CMAKE_CURRENT_SOURCE_DIR}/Monitor_Control
  ${CMAKE_CURRENT_SOURCE_DIR}/ETCL
  ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders
  ${CMAKE_CURRENT_SOURCE_DIR}/QoS
  ${CMAKE_CURRENT_SOURCE_DIR}/QtReactor
  ${CMAKE_CURRENT_SOURCE_DIR}/SSL
  ${CMAKE_CURRENT_SOURCE_DIR}/TkReactor
  ${CMAKE_CURRENT_SOURCE_DIR}/XML_Utils
  ${CMAKE_CURRENT_SOURCE_DIR}/XtReactor
  ${CMAKE_SOURCE_DIR}/dep/zlib
)

# Needed for PCH support
set_source_files_properties(Atomic_Op_Sparc.c Rtems_init.c PROPERTIES LANGUAGE CXX)

add_definitions(-DACE_BUILD_DLL)

add_library(ace SHARED
  ${ace_STAT_SRCS}
)

target_include_directories(ace 
  PUBLIC
  ${CMAKE_SOURCE_DIR}/dep/acelite
  ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders
  ${CMAKE_SOURCE_DIR}/dep/zlib
)

target_link_libraries(ace 
    trinity-dependency-interface
    trinity-no-warning-interface
)
	  
set_target_properties(ace PROPERTIES LINKER_LANGUAGE CXX)

set_target_properties(ace
  PROPERTIES
    FOLDER
      "dep")

if (MINGW) # GCC ignores "#prama comment"
  target_link_libraries(ace ws2_32 iphlpapi netapi32 mswsock)
endif()

# Generate precompiled header
if( USE_COREPCH )
  add_cxx_pch(ace ${ace_PCH_HDR})
endif()

install(TARGETS ace RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
